package com.beasts.antpage.core.entity.content;

import com.beasts.antpage.core.utils.servlet.RequestUtil;
import com.beasts.antpage.core.utils.unique.UUIDUtil;
import lombok.Data;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * TODO 链接管理
 *
 * @author Locker
 * @date 25/06/2018 11:17 AM
 * @since 1.0
 */
@Data
public class ApLink implements Serializable {

    private String id;

    /**
     * 链接标题
     */
    private String title;

    /**
     * 链接地址
     */
    private String url;

    /**
     * 链接图片地址
     */
    private String img;

    /**
     * 排序
     */
    private Integer ordIndex;

    /**
     * 0 图片链接
     * 1 文字链接
     * 2 图片和文字链接
     */
    private String type;

    public ApLink() {
    }

    public ApLink(HttpServletRequest req) {
        this.id = RequestUtil.getValue(req, "id", UUIDUtil.get(true));
        this.title = RequestUtil.getValue(req, "title", "");
        this.url = RequestUtil.getValue(req, "url", "");
        this.img = RequestUtil.getValue(req, "img", "");
        this.ordIndex = Integer.parseInt(RequestUtil.getValue(req, "ordIndex", "0"));
        this.type = RequestUtil.getValue(req, "type", "");
    }

}
